<?php

namespace App\Models\Backend\System;

use Illuminate\Database\Eloquent\Model;

class Role extends Model
{
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [
        'rolename','roledes'
    ];

    /**
     * 角色拥有的权限
     */
    public function powers()
    {
        return $this->belongsToMany(Operation::class, 'rolepowers', 'role_id', 'actionid');
    }

    /**
     * 角色对应的用户
     */
    public function users()
    {
        return $this->belongsToMany(User::class)->orderBy('group_id');
    }
}
